<?php

use yii\helpers\Url;
use yii\helpers\Html;
use common\helpers\Render;

$navigator = [
    '0' => [
        'idnex' => ['action' => 'designer/index', 'icon' => 'star','title' => '个人中心'],

        'information' => [
            'action' => '', 'title' => '个人设置', 'icon' => 'gear', 'sub' => [
                'information' => ['action' => 'designer/informationo', 'title' => '个人资料'],
                'change-mobile' => ['action' => 'user/change-mobile', 'title' => '修改手机'],
                'change-password' => ['action' => 'user/change-password', 'title' => '修改密码'],
            ]
        ],
        'account' => [
            'action' => '', 'title' => '资金管理', 'icon' => 'credit-card', 'sub' => [
                'wallet' => ['action' => 'designer/wallet', 'title' => '我的钱包'],
                'balance-change' => ['action' => 'user/balance-change', 'title' => '资金明细'],
                'bond' => ['action' => 'designer/bondo', 'title' => '保证金管理'],
            ]
        ],
        'design' => [
            'action' => '', 'title' => '作品管理', 'icon' => 'flag', 'sub' => [
                'design-list' => ['action' => 'designer/design-list', 'title' => '我的作品'],
                'design' => ['action' => 'designer/design', 'title' => '发布作品'],
            ]
        ],
        'recruit-applicant-list' => [
            'action' => '', 'title' => '简历管理', 'icon' => 'flag', 'sub' => [
                'design-list' => ['action' => 'designer/recruit-applicant-list', 'title' => '投递管理'],
                'design' => ['action' => 'designer/resume', 'title' => '发布简历'],
            ]
//            'action' => 'designer/recruit-applicant-list', 'title' => '投递管理', 'icon' => 'inbox',
//            'action' => 'designer/resume','title'=>'发布简历', 'icon' => 'inbox',
        ],
        'employment-list' => [
            'action' => 'designer/employment-list', 'title' => '我的服务', 'icon' => 'cloud',
        ],
        'message' => [
            'action' => 'user/message-list', 'title' => '我的消息', 'icon' => 'comments',
        ],
        'collection' => [
            'action' => '', 'title' => '我的收藏', 'icon' => 'heart', 'sub' => [
                'collection-recruit-list' => ['action' => 'designer/collection-recruit-list', 'title' => '招聘收藏'],
            ]
        ],
//        'coupon-list' => [
//            'action' => 'designer/coupon-list', 'title' => '我的优惠劵', 'icon' => 'gift',
//        ],
//        'activity' => [
//            'action' => 'designer/activity', 'title' => '活动专区', 'icon' => 'fire',
//        ],
    ],
    '1' => [
        'idnex' => ['action' => 'employer/index', 'icon' => 'star','title' => '个人中心'],
        'information' => [
            'action' => '', 'title' => '个人设置', 'icon' => 'gear', 'sub' => [
                'information' => ['action' => 'employer/information', 'title' => '个人资料'],
                'change-mobile' => ['action' => 'user/change-mobile', 'title' => '修改手机'],
                'change-password' => ['action' => 'user/change-password', 'title' => '修改密码'],
            ]
        ],
        'account' => [
            'action' => '', 'title' => '资金管理', 'icon' => 'credit-card', 'sub' => [
                'wallet' => ['action' => 'employer/wallet', 'title' => '我的钱包'],
                'balance-change' => ['action' => 'user/balance-change', 'title' => '资金明细'],
            ]
        ],
        'recruit' => [
            'action' => '', 'title' => '招聘管理', 'icon' => 'flag', 'sub' => [
                'recruit-list' => ['action' => 'employer/recruit-list', 'title' => '我的招聘'],
                'recruit' => ['action' => 'employer/recruit', 'title' => '发布招聘'],
            ]
        ],
        'employment-list' => [
            'action' => 'employer/employment-list', 'title' => '我的服务', 'icon' => 'cloud',
        ],
        'message' => [
            'action' => 'user/message-list', 'title' => '我的消息', 'icon' => 'comments',
        ],
        'collection' => [
            'action' => '', 'title' => '我的收藏', 'icon' => 'heart', 'sub' => [
                'collection-designer-list' => ['action' => 'employer/collection-designer-list', 'title' => '简历收藏'],
                'collection-design-list' => ['action' => 'employer/collection-design-list', 'title' => '作品收藏'],
            ]
        ],
        'coupon-list' => [
            'action' => 'employer/coupon-list', 'title' => '我的优惠劵', 'icon' => 'gift',
        ],
//        'activity' => [
//            'action' => 'employer/activity', 'title' => '活动专区', 'icon' => 'fire',
//        ],
    ]
];
?>
<link rel="stylesheet" href="<?= Url::to('@web/web/static/css/user.css') ?>">

<?= $this->render('/layouts/break-crumbs') ?>

<div id="user-navigator">
    <div class="box-shadow" id="user-photo">
        <div class="imager"><a href="<?= Url::to('@web/user/photo') ?>"><img src="<?= Render::upload(\Yii::$app->getUser()->photo) ?>"></a></div>
        <div class="username">ID: <?= \Yii::$app->getUser()->nickname ?></div>
    </div>
    <div class="box-shadow mt-10px" id="sub-navigator">
        <?php
        $role = \Yii::$app->getUser()->role;
        foreach($navigator[$role] as $key => $nav) {
            if(isset($nav['action']) && $nav['action']) {
                $nav['title'] = '<a href="'.Url::to('@web/'.$nav['action']).'"><i class="icon-'.$nav['icon'].'"></i> '.$nav['title'].' <i class="icon-angle-down"></i></a>';
            }
            else {
                $nav['title'] = "<i class=\"icon-{$nav['icon']}\"></i> {$nav['title']} <i class=\"icon-angle-down\"></i>";
            }
            echo '<h3 class="'.(((isset($nav['sub']) && key_exists($active, $nav['sub'])) || ($active == $key)) ? 'active' : '').'">'.$nav['title'].'</h3>';
            if(isset($nav['sub'])) {
                echo '<div class="second">';
                foreach($nav['sub'] as $k => $n) {
                    $url = Url::to('@web/'.$n['action']);
                    echo '<a class="'.(($active == $k) ? 'active' : '').'" href="'.$url.'"><i class="icon-double-angle-right"></i> '.$n['title'].'</a>';
                }
                echo '</div>';
            }
        }
        ?>
    </div>
</div>